package com.lyx.dao;

import com.lyx.domain.Member;
import com.lyx.domain.Orders;
import com.lyx.domain.Product;
import com.lyx.domain.Traveller;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface IOrderDao {

 @Select("select * from orders")
 @Results({
     @Result(id = true,property = "id",column = "id"),
     @Result(property = "orderNum",column = "orderNum"),
     @Result(property = "orderTime",column = "orderTime"),
     @Result(property = "orderStatus",column = "orderStatus"),
     @Result(property = "peopleCount",column = "peopleCount"),
     @Result(property = "payType",column = "payType"),
     @Result(property = "orderDesc",column = "orderDesc"),
     @Result(property = "product", column = "productId", javaType = Product.class, one = @One(select = "com.lyx.dao.IProductDao.findById")),
 })
 public List<Orders> findAll() throws Exception; //查询所有订单

 @Select("select * from orders where id=#{id}")
 @Results({
         @Result(id = true,property = "id",column = "id"),
         @Result(property = "orderNum",column = "orderNum"),
         @Result(property = "orderTime",column = "orderTime"),
         @Result(property = "orderStatus",column = "orderStatus"),
         @Result(property = "peopleCount",column = "peopleCount"),
         @Result(property = "payType",column = "payType"),
         @Result(property = "orderDesc",column = "orderDesc"),
         @Result(property = "product", column = "productId", javaType = Product.class, one = @One(select = "com.lyx.dao.IProductDao.findById")),
         @Result(property = "travellers" ,column = "id",  many = @Many(select = "com.lyx.dao.ITravellerDao.findByOrdersId")),
         @Result(property = "member" ,column = "memberId", javaType = Member.class,  one = @One(select = "com.lyx.dao.IMemberDao.findById")),
 })
 public Orders findById(String id) throws Exception;


}
